package com.wang.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * controller的返回结果统一使用该类进行包装    返回结果包装类
 */
public class R {
    // 状态码
    private Integer code;

    // 结果信息
    private String msg;

    //数据
    private Object data;

    public R(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public R() {
    }

    public static R OK(Object data) {
        return new R(200, "成功", data);
    }

    public static R OK(){
        return new R(200,"成功",null);
    }
    public static R FALSE(){
        return new R(500,"失败",null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
